# Label（标签）组件用于在屏幕上显示文本或图像
import tkinter as tk
# 建立窗口
window = tk.Tk()
window.title('hello thinter')
height= window.winfo_screenheight()
width= window.winfo_screenwidth()
window.geometry('400x200+%d+%d'%((width-400)/2,(height-200)/2))
tk.Label(window, text="这是Label文本！").pack()
window.mainloop()
# 一、字体颜色、字体样式

import tkinter as tk
# 建立窗口
window = tk.Tk()
window.title('hello thinter')
height= window.winfo_screenheight()
width= window.winfo_screenwidth()
window.geometry('400x200+%d+%d'%((width-400)/2,(height-200)/2))
tk.Label(window, text="这是Label文本！",font=("华文行楷", 20),fg="green").pack()
window.mainloop()
# 二、改变Label的值

import tkinter as tk
# 建立窗口

def A():
    v.set("改变文本")

window = tk.Tk()
window.title('hello thinter')
height= window.winfo_screenheight()
width= window.winfo_screenwidth()
window.geometry('400x200+%d+%d'%((width-400)/2,(height-200)/2))
v = tk.StringVar()
text = tk.Label(window,font=("华文行楷", 20),fg="green",textvariable=v).pack()
v.set("文本")
tk.Button(window,text="按钮",command=A).pack()
window.mainloop()
# 三、显示图片


import tkinter as tk
# 建立窗口


window = tk.Tk()
window.title('hello thinter')
height= window.winfo_screenheight()
width= window.winfo_screenwidth()
window.geometry('400x200+%d+%d'%((width-400)/2,(height-200)/2))
photo = tk.PhotoImage(file="/Users/liuhaoyu/Desktop/2023/WechatIMG74447.png")
w = tk.Label(window, image=photo)
w.pack()
window.mainloop()
 